<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<html:html>
<head>	
	<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/css/sampleForm.css" />
	<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/css/me.css" />	
	<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/help/help.css" />
	<title>บันทึกใบซื้ออุปกรณ์, วัตถุดิบ (BCAPInvoice, BCAPInvoiceSub)</title>
	<script type='text/javascript' src='/ittl/dwr/interface/BCProjectService.js'></script>
  	<script type='text/javascript' src='/ittl/dwr/interface/BCItemService.js'></script>
	<script type='text/javascript' src='/ittl/dwr/interface/BCAPService.js'></script>
  	  	
  	<script type='text/javascript' src='/ittl/dwr/interface/BCAPInvoiceService.js'></script>
  	<script type='text/javascript' src='/ittl/dwr/engine.js'></script>
  	<script type='text/javascript' src='/ittl/dwr/util.js'></script>

	<script type='text/javascript' src='<%= request.getContextPath() %>/css/autocomplete/lib/jquery.js' ></script>
	<script type='text/javascript' src='<%= request.getContextPath() %>/css/autocomplete/lib/jquery.autocomplete.js' ></script>
		
	<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/css/autocomplete/css/mainOLD.css" />
	<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/css/autocomplete/css/jquery.autocomplete.css" />
	<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/css/autocomplete/css/thickbox.css" />
 
 	<script type="text/javascript" src="<%= request.getContextPath() %>/stockRequest/jquery.validate.js" ></script>
 	<script type="text/javascript" src="<%= request.getContextPath() %>/stockRequest/jquery-1.4.2.min1.js" ></script>
 	
	<link type="text/css" href="<%= request.getContextPath() %>/css/datepicker/css/ui.all.css" rel="stylesheet" /> 	
	<script type="text/javascript" src="<%= request.getContextPath() %>/css/datepicker/lib/jquery-ui-1.5.3.min.js"></script>	
	<script type="text/javascript">
		$(document).ready(function(){

			$("#form1").submit(function(){
				var i = 0;
				var docNo = $("#docNo").val();				
				var docDate = $("#docDate").val();
				var departCode = $("#departCode").val();
				var apCode = $("#apCode").val();

				var sumOfItemAmount = parseFloat($("#sumOfItemAmount").val()); 
				sumOfItemAmount = isNaN(sumOfItemAmount)? 0:sumOfItemAmount;
				
				var taxAmount = parseFloat($("#taxAmount").val());
				taxAmount = isNaN(taxAmount)? 0:taxAmount;
				
				var	totalAmount = parseFloat($("#totalAmount").val());
				totalAmount = isNaN(totalAmount)? 0:totalAmount; 
				
				var	netAmount = parseFloat($("#netAmount").val());
				netAmount = isNaN(netAmount)? 0:netAmount;

					
				if(docNo==null   || docNo=="") 			{	i++;	$('#docNo_error').text("*");}
				if(docDate==null || docDate=="") 		{	i++;	$('#docDate_error').text("*");}
				if(departCode==null || departCode=="") 	{	i++;	$('#departCode_error').text("*");}
				if(apCode==null  || apCode=="") 		{	i++;	$('#apCode_error').text("*");}

				if(sumOfItemAmount<=0) {	i++;	$('#sumOfItemAmount_error').text("*");}
				if(taxAmount<=0) 	{	i++;		$('#taxAmount_error').text("*");}
				if(totalAmount<=0){	i++;	$('#totalAmount_error').text("*");	



				}
				if(netAmount<=0) 	{	i++;	$('#netAmount_error').text("*");}

				
				$('#cart tbody tr').each(function() {

					var qty = parseFloat($('td.qty input', this).val());
					qty = isNaN(qty)? 0:qty;
					if(qty<=0) {	i++;	$('#qty_error').text("*");}

					var price = parseFloat($('td.price input', this).val());
					price = isNaN(price)? 0:price;
					if(price<=0) {	i++;	$('#price_error').text("*");}
					
					var amount = parseFloat($('td.amount input', this).val());
					amount = isNaN(amount)? 0:amount;
					if(amount<=0) {	i++;	$('#amount_error').text("*");}
					
				});	
			//	alert("i = "+i);
				if(i>0) {
					
					return false;
				}else {
					return true;
				}
				
			});
			
			$("#docDate").datepicker({ altField: 'input#docDate', altFormat: 'yy-mm-dd' });
			$("#taxDate").datepicker({ altField: 'input#taxDate', altFormat: 'yy-mm-dd' });
			$("#statementDate").datepicker({ altField: 'input#statementDate', altFormat: 'yy-mm-dd' });
			$("#dueDate").datepicker({ altField: 'input#dueDate', altFormat: 'yy-mm-dd' });

			$('#summary tbody tr td.taxRate input').keypress(function(event){ 	
		 		checkForNumber(event,$(this).val());
		 	});
			
	 		$('td.qty input').keypress(function(event){ 	
		 		checkForNumber(event,$(this).val());
		 	});

	 		$('td.qty input').blur(function(){
	 			var sumOfItemAmount = 0;
				
				$('#cart tbody tr').each(function() {
					var price = parseFloat($('td.price input', this).val());
					price = isNaN(price)? 0:price;
					//alert("price="+price);
					
					var qty = parseInt($('td.qty input', this).val());
					qty = isNaN(qty)?0:qty;
					
					var lineItemDiscountAmount = $('td.lineItemDiscountAmount input', this).val();
					var percent = checkPercent(lineItemDiscountAmount);
			  		var discountAmount = parseFloat(lineItemDiscountAmount);					
			  		discountAmount = isNaN(discountAmount)?0:discountAmount;

					if(percent==true) {
						amount = qty*price-qty*price*discountAmount/100;
					}else {
						amount = qty*price-discountAmount;
					}
					var amount = isNaN(amount)? 0:amount;
					
					$('td.amount input', this).val(amount.toFixed(2));
					sumOfItemAmount += amount;		
				});
								
				summary(sumOfItemAmount);

								
		 	});	
	 		 		
	 		$('td.price input').keypress(function(event){	checkForNumber(event,$(this).val() );	});
	 		$('td.price input').blur(function(){
	 			var sumOfItemAmount = 0;
				
				$('#cart tbody tr').each(function() {
					var price = parseFloat($('td.price input', this).val());
					price = isNaN(price)? 0:price;

					var qty = parseInt($('td.qty input', this).val());
					qty = isNaN(qty)?0:qty;

					var lineItemDiscountAmount = $('td.lineItemDiscountAmount input', this).val();
					var percent = checkPercent(lineItemDiscountAmount);
			  		var discountAmount = parseFloat(lineItemDiscountAmount);					
			  		discountAmount = isNaN(discountAmount)?0:discountAmount;
					
					if(percent==true) {
						amount = qty*price-qty*price*discountAmount/100;
					}else {
						amount = qty*price-discountAmount;
					}
					var amount = isNaN(amount)? 0:amount;

					$('td.price input', this).val(price.toFixed(2));
					$('td.amount input', this).val(amount.toFixed(2));		
					sumOfItemAmount += amount;																		
				});

				summary(sumOfItemAmount);

		 	});

	 		    	  	  	
	 		$('td.lineItemDiscountAmount input').keypress(function(event){	checkForNumberPercent(event,$(this).val() );	});
	 		$('td.lineItemDiscountAmount input').blur(function(){
	 			var sumOfItemAmount = 0;
				
				$('#cart tbody tr').each(function() {
					var price = parseFloat($('td.price input', this).val());
					price = isNaN(price)? 0:price;

					var qty = parseInt($('td.qty input', this).val());
					qty = isNaN(qty)?0:qty;

					var lineItemDiscountAmount = $('td.lineItemDiscountAmount input', this).val();
					var percent = checkPercent(lineItemDiscountAmount);
			  		var discountAmount = parseFloat(lineItemDiscountAmount);					
			  		discountAmount = isNaN(discountAmount)?0:discountAmount;
					
					if(percent==true) {
						amount = qty*price-qty*price*discountAmount/100;
					}else {
						amount = qty*price-discountAmount;
					}
					var amount = isNaN(amount)? 0:amount;

					if(discountAmount==0)
						$('td.lineItemDiscountAmount input', this).val("0.00");
					
					$('td.amount input', this).val(amount.toFixed(2));		
					sumOfItemAmount += amount;																														
				});
				
				summary(sumOfItemAmount);

		 	});
		 		 		
	 		$('td.amount input').keypress(function(event){	checkForNumber(event,$(this).val() );	});
	 		$('td.amount input').blur(function(){
	 			var sumOfItemAmount = 0;
				
				$('#cart tbody tr').each(function() {
					
					var amount = parseFloat($('td.amount input', this).val());
					$('td.amount input', this).val(amount.toFixed(2)); 
					amount = isNaN(amount)? 0:amount;

					var qty = parseInt($('td.qty input', this).val());
					qty = isNaN(qty)?0:qty;
					var lineItemDiscountAmount = $('td.lineItemDiscountAmount input', this).val();
					var percent = checkPercent(lineItemDiscountAmount);
			  		var discountAmount = parseFloat(lineItemDiscountAmount);					
			  		discountAmount = isNaN(discountAmount)?0:discountAmount;
			  		
					var price = 0;
					if(percent==true) {
						price = (amount+(amount*discountAmount/(100-discountAmount)))/qty;
					}else {
						price = (amount+discountAmount)/qty;
					}					
					$('td.price input', this).val(price.toFixed(2));
					
					sumOfItemAmount += amount;																		
				});	
				summary(sumOfItemAmount);
		 	});

	 		$('td.discountAmount input').keypress(function(event){	checkForNumberPercent(event,$(this).val() );	});
	 		$('td.discountAmount input').blur(function(){
	 			var sumOfItemAmount = 0;
	 			$('#cart tbody tr').each(function() {
	 				var amount = parseFloat($('td.amount input', this).val());
					$('td.amount input', this).val(amount.toFixed(2)); 
					amount = isNaN(amount)? 0:amount;
					sumOfItemAmount += amount;	
	 			});
		 		
	 			var discountAmount = $('#summary tbody tr td.discountAmount input').val();
	 			var percent = checkPercent(discountAmount);
	 			var disAmt = parseFloat(discountAmount);	 			
	 			disAmt = isNaN(disAmt)?0:disAmt;

	 			
	 			if(percent==true){
	 				sumOfItemAmount = sumOfItemAmount-sumOfItemAmount*disAmt/100;
		 		}else {
		 			sumOfItemAmount = sumOfItemAmount-disAmt;
		 			//$('#summary tbody tr td.discountAmount input').val(disAmt.toFixed(2));
			 	}
			 		 			
	 			$('#summary tbody tr td.sumOfItemAmount input').val(sumOfItemAmount);				
				summary(sumOfItemAmount);
				
		 	});
		 	    	 		
   		});
 
	</script>


<script type="text/javascript" >
function summary(sumOfItemAmount) {
	$('#summary tbody tr td.sumOfItemAmount input').val(sumOfItemAmount.toFixed(2));				
	var taxRate = $('#summary tbody tr td.taxRate input').val();
	var taxAmount = Math.round(sumOfItemAmount*taxRate/100*100)/100;
	$('#summary tbody tr td.taxAmount input').val(taxAmount.toFixed(2));	
	var totalAmount = sumOfItemAmount+taxAmount;
	$('#summary tbody tr td.totalAmount input').val(totalAmount.toFixed(2));
	$('#summary tbody tr td.netAmount input').val(totalAmount.toFixed(2));

	var discountAmount = $('#summary tbody tr td.discountAmount input').val();
	var percent = checkPercent(discountAmount);
	var disAmt = parseFloat(discountAmount);
	disAmt = isNaN(disAmt)?0:disAmt;
	if(percent==false) {
		$('#summary tbody tr td.discountAmount input').val(disAmt.toFixed(2));
	}	
}

function checkPercent(val) {
	
	var percent = false;
	if(val.length>0) {
	  	var digit = val.charAt(val.length-1);
	  	if(digit=="%") {
	  		return true;		
  	  	}
	}
	return false;
}

function checkForNumber(event, val) {
	if(event.which && ( event.which<48 || event.which>57) ) {

			if(event.which!=46 ) {
				event.preventDefault();
 	  		}else {
 				var a = val;
 	  			for(var i=0; i<a.length;i++) {
  	  			digit = a.charAt(i);
  	  			if(digit==".") {        			  	  			
	  	  			event.preventDefault();
	  	  		}
  	  		}
  	  	}        	  	  		  	  		
  	}
}
function checkForNumberPercent(event, val) {
	
//	alert(event.which);
//	alert(val);
	if(event.which!=0 && event.which!=8) {
		if(event.which && ( event.which<48 || event.which>57) ) {
			
			if(event.which!=46 && event.which!=37) {
				event.preventDefault();
		  	}else {
				var a = val;
		  		for(var i=0; i<a.length;i++) {
	 	  			digit = a.charAt(i);
	 	  			if(event.which==46 && digit==".") {        			  	  			
	  	  				event.preventDefault();
	  	  			}else if(event.which==37 && digit=="%") {
	  	  				event.preventDefault();
		  	  		}
		  		}
	 	  	}        	  	  		  	  		
	  	}else {
			var a = val;
	  		for(var i=0; i<a.length;i++) {
		  		digit = a.charAt(i);
		  		if(digit=="%") {
		  			event.preventDefault();
	  	  		}
	  		}  		  	
	  	}
	}
}

function modalWin(aa) {
	if (window.showModalDialog) {		
		window.showModalDialog(aa,"name","dialogTop:100px;dialogWidth:650px;dialogHeight:350px;center:yes");
	} else {		
		window.open(aa,'name','height=350,width=600,toolbar=no,directories=no,status=no,continued from previous linemenubar=no,scrollbars=no,resizable=no ,modal=yes');
	}
}
function modalWinItem(aa) {
	if (window.showModalDialog) {		
		window.showModalDialog(aa,"name","dialogTop:100px;dialogWidth:650px;dialogHeight:350px;center:yes");
	} else {		
		window.open(aa,'name','height=350,width=600,toolbar=no,directories=no,status=no,continued from previous linemenubar=no,scrollbars=no,resizable=no ,modal=yes');
	}
}

function getDocDateToTaxDate() {
	document.getElementById('taxDate').value = document.getElementById('docDate').value;
}
</script>

<style type="text/css">
#form1 label.error {
	font-size: 1.0em;
	color: red;
}
#docNo_error, #docDate_error, #departCode_error, #apCode_error, #qty_error, #price_error, #amount_error, 
#sumOfItemAmount_error, #taxAmount_error, #totalAmount_error, #netAmount_error {
	font-size: 1.5em;
	color: red;
}
</style>
</head>

<body onload="displayDate()" ><br />
<div id="wrapper">
	 
	<div id="menu"><ul id="nav"></ul></div>

	<div id="content">
		<div id="menuNav"><a href='<%=request.getContextPath() %>/Login.do?mode=check'>หน้าหลัก</a> 
		
	</div><br />
			
	<div style="background: #ffffff;">
	<p align="center" id="titleIssueType">บันทึกใบสั่งซื้อ </p>
			
	<html:form action="/chemicalpo.do"  styleId="form1"  >	        
                <html:hidden property="creatorCode" value="${userName }" />
                
	<div id="userPw01">
	<fieldset>
		<legend><b>ข้อมูลใบสั่ง สีเคมี</b></legend>
		   <table border="0" >
		   		   
			<tr>
				<td width="160" align="right">เลขที่ใบสั่งซื้อ:</td>
				<td width="120">
					<html:text property="docNo" styleId="docNo" value="${p.docNo}" readonly="true" 
						errorKey="org.apache.struts.action.ERROR" style="width:135px"   />
					<html:errors property="docNo" />
					<span id="docNo_error"></span>
				</td>
				<td width="10">
					
				</td>				
				<td width="120" align="right"> วันที่ออกเอกสาร:</td>
				<td ><html:text 	property="docDate" styleId="docDate" value="${p.docDate }" style="width:115px"
											errorKey="org.apache.struts.action.ERROR" readonly="false" 
											
											/>
								<html:errors property="docDate" /><span id="docDate_error"></span>
				</td>
				<td width="10"></td>					
			</tr>
			<tr>
				<td width="160" align="right">ประเภทภาษี:</td>
				<td ><html:select property="taxType" value="${p.taxType }" styleId="taxType" 
																onchange='calTaxType(this)' style="width:135px">
									<html:option value="0">ภาษีแยกนอก</html:option>
									<html:option value="1">ภาษีรวมใน</html:option>
									<html:option value="2">ภาษีอัตราศูนย์</html:option>
								</html:select></td>
				<td width="20"></td>				
				<td align="right">แผนก:</td>
				<td width="140"><html:text property="departCode" value="${p.departCode }" styleId="departCode" 
								style="width:115px"  />
					<html:errors property="departCode" /><span id="departCode_error"></span>
								</td>
				<td width="20"></td>
			</tr>			
			<tr>			
 				<td align="right">รหัสเจ้าหนี้:</td>
 				<td> 
 					<html:text property="apCode" value="${p.apCode }" styleId="apCode" readonly="false" style="width:135px"
 								onchange="getAP()"
						  		onblur="getAP()" 
 					/>
 					<html:errors property="apCode" /><span id="apCode_error"></span>										 					 					 					 					
 				</td>
 				<td ><a href="#" target="name" onclick="modalWinItem('/ittl/apinvoice/ap.do?mode=apFind'); return false;">ค้น</a></td> 				
 				<td colspan="3">
 					&nbsp;<html:text property="apName" value="${p.tempMyDesc7 }" size="40" styleId="apName" style="width:240px" readonly="true"/>
 					<span id="apName_error"></span>
 				</td> 										 				 			
 			</tr>

 			<tr>
 				<td align="right">TTL PurchaseCode:</td>
 				<td colspan="4">
 					<html:text property="tempMyDesc2" value="${p.tempMyDesc2}" size="250" styleId="tempMyDesc2" style="width:387px" />
 				</td>
 				<td>(หมายเหตุ 2)</td> 				
 			</tr>
 
 			<tr>
 				<td align="right">หมายเหตุ(PO):</td>
 				<td colspan="5">
 					<html:text property="myDescription" value="${p.myDescription }" size="250" styleId="myDescription" style="width:387px" />
 				</td> 				
 			</tr> 						 																 			 				 							
		</table>
		</center>
     </fieldset></div>
<div id="items"> 
     <fieldset>
     	<legend><b>รายการ สีเคมี</b></legend>     	
     	      	     	
     	<p><!--<a href="#" onClick="addFormField(); return false;">
     			<img src="<%=request.getContextPath() %>/common/images/add.png" width="24" height="24" alt="Add" />เพิ่มรายการ
     		</a>     			   
     		--><input type="hidden" id="countId" value="${countId }">
     	</p>
     	
		<table border="1" id="cart">
			<thead>
				<tr id="rHead">
					<th width="24">&nbsp;</th>
				  <th width="100" align="center">รหัสสินค้า</th>
				  <th width="10">&nbsp;</th>
				  <th width="270" align="center">ชื่อรายการ</th>
				  				

				  <th width="70"  align="center">หน่วยนับ</th>
				  
				  <th width="60"  align="center">จำนวน</th>
				  
				  <th width="60"  align="center">ราคาซื้อ</th>
				  				
				  <th width="60"  align="center">ส่วนลด</th>
				  				    
				  <th width="70"  align="center">จำนวนเงิน</th>
				  				  
				  <th width="10">&nbsp;</th>
				  			
				</tr>						
			</thead>
			
			<tbody id="inputs" >								 								
					<logic:iterate name="sub" id="aa" indexId="id">									     					     
						<tr id="r${id+1 }">
							<td valign="middle" >
								
									<a href='#' onClick="removeFormField('#r${id+1}',${id+1}); return false;">
										<img src="<%=request.getContextPath() %>/common/images/remove.png" width="24" height="24" alt="Remove" />
									</a>								
							</td>								
						  	<td>						  		
						  		<html:text property="itemCode" value="${aa.itemCode}" styleId="itemCode${id+1}" size="15"						  				 
						  					style="align:right;width:100px" readonly="true" />
						  		<html:errors property="itemCode${id+1}" />						  								  							  		
						  	</td>
						  	<td><!--<a href="#" target="name" onclick="modalWinItem('/ittl/apinvoice/apinvoice2.do?mode=moreItemsShow&lineNumber=${id+1 }'); return false;">ค้น</a>--></td>
							<td><html:text property="itemName" value="${aa.itemName}" maxlength="200" size="40" styleId="itemName${id+1}" />
											<html:errors property="itemName${id+1}" />				
							</td>												
							<td><html:select property="unitCode">
									<html:option value="007">KGs.</html:option>
								</html:select>						
							</td>
							<td class="qty">
								<html:text property="qty" value="${aa.qty }" size="7" styleId="qty${id+1}" onblur="calLineItem(${id+1});" style="text-align:right;width:60px"  />
								<html:errors property="qty${id+1}" /><span id="qty_error"></span>								
							</td>
							
							<td class="price">
								<html:text property="price" value="${aa.price }" size="7" styleId="price${id+1}" style="text-align:right;width:60px" />
								<html:errors property="price${id+1}" /><span id="price_error"></span>								
							</td>
							
							<td class="lineItemDiscountAmount">
								<html:text property="lineItemDiscountAmount" value="${aa.discountAmount }" size="7" styleId="lineItemDiscountAmount${id+1}"  style="text-align:right;width:60px"  />
								<html:errors property="lineItemDiscountAmount${id+1}" />								
							</td>
												
							<td class="amount">
								<html:text property="amount" value="${aa.amount}" styleId="amount${id+1}" 
									size="10"   style="text-align:right;width:80px" />
										<html:errors property="amount${id+1}" /><span id="amount_error"></span>																									
							</td>								
							
							<td><a href="#" target="name" onclick="modalWinItem2('/ittl/purchaseOrder/chemicalpo.do?mode=chemicalHistory&lineNumber=${id+1 }&itemCode=${aa.itemCode }&dept=${dept }',1200); return false;">
				  		<img src="../images/Find2.bmp"></a>  </td>												
						</tr>
																																								
					</logic:iterate>										
																								
			</tbody>					
		</table>
		<br/>  
			
		<!--<font size='2'>หมายเหตุ : <font color="red">Item ที่ลบได้ </font>คือข้อมูลที่เพิ่มเข้าไปใหม่</font>
		
		
     --></fieldset>
 	</div>    
 	<div id="userPw01">
	<fieldset>
		
		   
		   <table border="0" id="summary">
		   <tbody>
			<tr>
				<td align="right">โครงการ:</td>
				<td><html:select property="projectCode" value="${p.projectCode }" styleId="projectCode" style="width:90px">
 						<html:option value=""></html:option>
						<html:optionsCollection name="projectList" label="code" value="code" />
					</html:select>
					
				</td>
				<td>&nbsp;</td>			
 				<td align="right">รหัสผู้ติดต่อ:</td>
 				<td width="90px">&nbsp; 				
 				</td>
 				<td ></td>				 				 				
 				<td align="right">ยอดรวมมูลค่าสินค้า:</td>
 				<td class="sumOfItemAmount" >
 					<html:text property="sumOfItemAmount" value="${p.sumOfItemAmount }" styleId="sumOfItemAmount"  style="text-align:right;width:90px" />
					<html:errors property="sumOfItemAmount" />
 					<span id="sumOfItemAmount_error"></span>
 					</td>
 				<td ></td>	
 			</tr>		   													
			<tr>
				<td align="right">เครดิต(วัน):</td>
 				<td>
					 					
 				</td>
				<td ></td>			
 				<td align="right">การจัดสรร:</td>
 				<td>
 					 
					
 				</td>
 				<td ></td>				 				 				
 				<td align="right">ส่วนลดบาท:</td>
 				<td class="discountAmount">
 					<html:text property="discountAmount" value="${p.discountAmount }" styleId="discountAmount" onchange="calTaxAmount();" style="text-align:right;width:90px" />
					<html:errors property="discountAmount" />
 					
 				</td>
 				<td ></td>	
 			</tr>
 			<tr>
 				<td align="right">เอกสารหมดอายุภายใน:</td>
 				<td> 					
 				</td>
 				<td ></td>
 				<td align="right">วันที่หมดอายุ:</td>
 				<td>
 															 				
 				</td>
 				<td ></td>
 				<td align="right">ภาษีมูลค่าเพิ่ม:</td>
 				<td class="taxAmount">
 					<html:text property="taxAmount" value="${p.taxAmount }" styleId="taxAmount"  style="text-align:right;width:90px" />
					<html:errors property="taxAmount"/>
					<span id="taxAmount_error"></span>					
 				</td>
 				<td ></td> 				 				 				
 			</tr>
 			<tr>
				<td align="right">ระยะเวลาขนส่ง:</td>
				<td>
										
				</td>
 				<td ></td>
 				<td align="right">กำหนดส่ง:</td>
 				<td>
 					
			 					 				
 				</td>
 				<td ></td> 				
 				<td align="right">มูลค่ารวมภาษี:</td>
 				<td class="totalAmount"> 					
 					<html:text property="totalAmount" value="${p.totalAmount }" styleId="totalAmount" style="text-align:right;width:90px"  />
					<html:errors property="totalAmount" />
					<span id="totalAmount_error"></span>	 					
 				</td>
 					
 				<td ></td>	 				 			 				 			 				 				
 			</tr>
 			<tr>
 				<td align="right">เงื่อนไขการรับสินค้า:</td>
 				<td>
 					 					
 				</td>
 				<td ></td>
 				<td align="right">อัตราภาษีมูลค่าเพิ่ม:</td>
 				<td class="taxRate"> 					
 					<html:text property="taxRate" value="${p.taxRate }" styleId="taxRate" style="text-align:right;width:90px"   />
 				</td>
 				<td ></td> 				
 				<td align="right">มูลค่าสินค้ายกเว้นภาษี:</td>
 				<td> 					
 					
					 					
 				</td>
 				<td ></td>	 				 			 				 			 				 				
 			</tr> 			 				 	
 			<tr>
 				<td align="right">รหัสสกุลเงิน:</td>
 				<td>
 				
					<html:select property="currencyCode" value="" style="width:90px">						
						<html:option value="BAHT">บาท</html:option>						
					</html:select> 				
 				 					
 				</td>
 				<td ></td>	

 				<td align="right">อัตราแลกเปลี่ยน:</td>
 				<td> 					
 					<html:hidden property="exchangeRate" value="" styleId="exchangeRate"   />
 				</td>
 				<td ></td>	

 				<td align="right">มูลค่าสุทธิ:</td>
 				<td class="netAmount">
 					<html:text property="netAmount" value="${p.netAmount }" styleId="netAmount" onchange="dataToPayAmount();" style="text-align:right;width:90px"  />
					<html:errors property="netAmount" /> 	
					<span id="netAmount_error"></span>				
 					</td>
 				<td ></td>	
 			</tr> 
 			</tbody>			 				 							
		</table>
		 
     </fieldset></div>
	      	
 	<table border="0" align="center" width="100%">
 		<tr>
 			<td align="center" ><html:submit property="mode" value="update" onclick="return confirm('ยืนยันการบันทึกข้อมูล?');"  /></td>
 			<td align="center" ><html:submit property="mode" value="delete" onclick="return confirm('ยืนยันการลบข้อมูล?');"  /></td>
			<td align="center" >
</td> 			
 		</tr>
 	</table>    	    	    	
    </html:form><br>
    </div>

<script type="text/javascript">

function modalWinItem2(link,width) {
	
	if (window.showModalDialog) {		
		window.showModalDialog(link,"name","dialogTop:200px;dialogLeft:650px;dialogWidth:"+width+"px;dialogHeight:500px;center:yes");
		//alert("true");
	} else {		
		window.open(link,'name','height=350,width=3000,toolbar=no,directories=no,status=no,continued from previous linemenubar=no,scrollbars=no,resizable=no ,modal=yes');
		//alert("true2");
	}
}
</script>


 
 </div>
 </div>
 
</body>
</html:html>